//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package messages;

import common.ByteStream;
import common.LogicLong;

import java.util.Date;

public class LoginOK extends Base {
    public static final int MsgType = 20104;
    public LogicLong AccountID;
    public LogicLong HomeID;
    public String PassToken;
    public String FaceBookID;
    public String GameCenterID;
    public int SessionCount;
    public int PlayTimeSeconds;
    public String ServerTime;
    public String AccountCreatedDate;
    public String ServerMode;
    public int ServerMajorVersion;
    public int ServerBuildVersion;
    public int ContentVersion;
    public int DaysSinceStartedPlaying;
    public int StartupCooldownSeconds;
    public String FaceBookAppID;
    public String UnkStr2;

    public LoginOK() {
        super(20104);
    }

    public void encode(ByteStream stream) {
    }

    public void decode(ByteStream stream) {
        if(this.version == 0 || this.version == 1) {
            this.AccountID = stream.readLong();
            if(this.version == 0) {
                stream.skip(8);
            }

            this.HomeID = stream.readLong();
            this.PassToken = stream.readString();
            this.FaceBookID = stream.readString();
            this.GameCenterID = stream.readString();
            if(this.version == 1) {
                this.ServerMajorVersion = stream.readInt();
                this.ServerBuildVersion = stream.readInt();
                this.ContentVersion = stream.readInt();
                this.ServerMode = stream.readString();
            } else {
                stream.readString();
            }

            this.SessionCount = stream.readInt();
            this.PlayTimeSeconds = stream.readInt();
            this.DaysSinceStartedPlaying = stream.readInt();
            if(this.version == 1) {
                this.FaceBookAppID = stream.readString();
            }

            if(!stream.isAtEnd()) {
                this.ServerTime = stream.readString();
                this.AccountCreatedDate = stream.readString();
                if(this.version == 1) {
                    this.StartupCooldownSeconds = stream.readInt();
                    this.UnkStr2 = stream.readString();
                }
            }

            this.isDecoded = true;
        }
    }

    public String toString() {
        if(this.isDecoded) {
            String retval;
            if(this.version == 0) {
                retval = String.format("     Account ID: %d\n     HomeID: %d\n     Pass Token: %s\n     FaceBook ID: %s\n     GameCenter ID: %s\n     Session Count: %d\n     Play Time is %d seconds\n     Unknown Integer: %d (0x%04x)\n", new Object[]{Long.valueOf(this.AccountID.longValue()), Long.valueOf(this.HomeID.longValue()), this.PassToken, this.FaceBookID, this.GameCenterID, Integer.valueOf(this.SessionCount), Integer.valueOf(this.PlayTimeSeconds), Integer.valueOf(this.DaysSinceStartedPlaying), Integer.valueOf(this.DaysSinceStartedPlaying)});
                if(this.ServerTime != null) {
                    retval = retval + "     Server Time: " + (new Date(Long.valueOf(this.ServerTime).longValue())).toString() + "\n";
                    retval = retval + "     Account Created: " + (new Date(Long.valueOf(this.AccountCreatedDate).longValue())).toString() + "\n";
                }

                return retval;
            } else {
                retval = String.format("     Account ID: %d\n     HomeID: %d\n     Pass Token: %s\n     FaceBook ID: %s\n     GameCenter ID: %s\n     Server Major Version: %d\n     Server Build Version: %d\n     Content Version: %d\n     Session Count: %d\n     Play Time is %d seconds\n     Days Since Started Playing: %d\n     FaceBook App ID: %s\n", new Object[]{Long.valueOf(this.AccountID.longValue()), Long.valueOf(this.HomeID.longValue()), this.PassToken, this.FaceBookID, this.GameCenterID, Integer.valueOf(this.ServerMajorVersion), Integer.valueOf(this.ServerBuildVersion), Integer.valueOf(this.ContentVersion), Integer.valueOf(this.SessionCount), Integer.valueOf(this.PlayTimeSeconds), Integer.valueOf(this.DaysSinceStartedPlaying), this.FaceBookAppID});
                if(this.ServerTime != null) {
                    retval = retval + "     Server Time: " + (new Date(Long.valueOf(this.ServerTime).longValue())).toString() + "\n";
                    retval = retval + "     Account Created: " + (new Date(Long.valueOf(this.AccountCreatedDate).longValue())).toString() + "\n";
                    retval = retval + String.format("     Startup Cooldown Seconds: %d\n", new Object[]{Integer.valueOf(this.StartupCooldownSeconds)});
                    retval = retval + "     Unknown String: " + this.UnkStr2 + "\n";
                }

                return retval;
            }
        } else {
            return super.toString();
        }
    }
}
